package com.exartisan.adapter;


import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import com.exartisan.yn_event.R;
import com.loopj.android.image.SmartImageView;

public class VideoAdapter extends BaseAdapter {
    
	private ArrayList<String> data;
	private LayoutInflater inflater;

	public VideoAdapter(Context ctx, ArrayList<String> d){
		this.data = d;
		inflater = LayoutInflater.from(ctx);
	}

    public int getCount() {
        return data.size();
    }

    public Object getItem(int position) {
        return position;
    }

    public long getItemId(int position) {
        return position;
    }
    
    public View getView(int pos, View convertView, ViewGroup parent) {
    	ViewHolder holder;
		if (convertView == null){
			holder = new ViewHolder();
			convertView = inflater.inflate(R.layout.row_gridview, null);
			holder.videoThumb = (SmartImageView) convertView.findViewById(R.id.item_video);
			convertView.setTag(holder);
		} else
			holder = (ViewHolder) convertView.getTag();
		holder.videoThumb.setImageUrl(data.get(pos));
		return convertView;
    }
    
    class ViewHolder{
		SmartImageView videoThumb;
	}
}